package com.learn.excel.core.common.exception;


import com.learn.excel.core.consts.ErrorCode;
import lombok.Data;

/**
 * @author: 杜海强
 * @description:
 * @date: 2021/4/16
 */
@Data
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    private Boolean logged;
    private String code;
    private String msg;

    public BusinessException(String errMsg) {
        super(errMsg);
        this.logged = false;
        this.code = ErrorCode.ERR_CODE_SYSTEM.getErrCode();
        this.msg = errMsg;
    }

    public BusinessException(String errMsg, boolean logged) {
        super(errMsg);
        this.logged = logged;
        this.code = ErrorCode.ERR_CODE_SYSTEM.getErrCode();
        this.msg = errMsg;
    }

    public BusinessException(String code, String errMsg) {
        super(errMsg);
        this.logged = false;
        this.code = code;
        this.msg = errMsg;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getErrMsg());
        this.logged = false;
        this.code = errorCode.getErrCode();
        this.msg = errorCode.getErrMsg();
    }

    public BusinessException(String code, String errMsg, boolean logged) {
        super(errMsg);
        this.logged = logged;
        this.code = code;
        this.msg = errMsg;
    }

    public BusinessException(String code, String errMsg, String msg, boolean logged) {
        super(errMsg);
        this.logged = logged;
        this.code = code;
        this.msg = msg;
    }

    public BusinessException(String errMsg, Throwable throwable, boolean logged) {
        super(errMsg, throwable);
        this.logged = logged;
        this.msg = errMsg;
    }

    public BusinessException(String code, String errMsg, Throwable throwable, boolean logged) {
        super(errMsg, throwable);
        this.logged = logged;
        this.code = code;
        this.msg = errMsg;
    }

    public BusinessException(String code, String errMsg, String msg, Throwable throwable, boolean logged) {
        super(errMsg, throwable);
        this.logged = logged;
        this.code = code;
        this.msg = msg;
    }
}
